package org.sport.model.entityModel;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;

/**
 * Created by Allen on 2017/9/29.
 */
@Entity
@Table(name = "grouptable", schema = "sportinfo", catalog = "")
public class GrouptableEntity {
    private Timestamp createTime;
    private String allUserTab;
    private String hisInfoTab;
    private String theam;
    private String title;
    private int id;
    private String icon;
    private String location;
    private Collection<GrouplinkuserEntity> grouplinkusersById;
    private UsertableEntity usertableByOwnerId;
    private Collection<HistoryinfotableEntity> historyinfotablesById;
    private Collection<LinkapplyhistoryEntity> linkapplyhistoriesById;

    @Basic
    @Column(name = "createTime", nullable = true)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "allUserTab", nullable = true, length = 45)
    public String getAllUserTab() {
        return allUserTab;
    }

    public void setAllUserTab(String allUserTab) {
        this.allUserTab = allUserTab;
    }

    @Basic
    @Column(name = "hisInfoTab", nullable = true, length = 45)
    public String getHisInfoTab() {
        return hisInfoTab;
    }

    public void setHisInfoTab(String hisInfoTab) {
        this.hisInfoTab = hisInfoTab;
    }

    @Basic
    @Column(name = "Theam", nullable = true, length = 45)
    public String getTheam() {
        return theam;
    }

    public void setTheam(String theam) {
        this.theam = theam;
    }

    @Basic
    @Column(name = "Title", nullable = true, length = 45)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Id
    @Column(name = "_id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "icon", nullable = true, length = 45)
    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    @Basic
    @Column(name = "location", nullable = true, length = 45)
    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GrouptableEntity that = (GrouptableEntity) o;

        if (id != that.id) return false;
        if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false;
        if (allUserTab != null ? !allUserTab.equals(that.allUserTab) : that.allUserTab != null) return false;
        if (hisInfoTab != null ? !hisInfoTab.equals(that.hisInfoTab) : that.hisInfoTab != null) return false;
        if (theam != null ? !theam.equals(that.theam) : that.theam != null) return false;
        if (title != null ? !title.equals(that.title) : that.title != null) return false;
        if (icon != null ? !icon.equals(that.icon) : that.icon != null) return false;
        if (location != null ? !location.equals(that.location) : that.location != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = createTime != null ? createTime.hashCode() : 0;
        result = 31 * result + (allUserTab != null ? allUserTab.hashCode() : 0);
        result = 31 * result + (hisInfoTab != null ? hisInfoTab.hashCode() : 0);
        result = 31 * result + (theam != null ? theam.hashCode() : 0);
        result = 31 * result + (title != null ? title.hashCode() : 0);
        result = 31 * result + id;
        result = 31 * result + (icon != null ? icon.hashCode() : 0);
        result = 31 * result + (location != null ? location.hashCode() : 0);
        return result;
    }

    @OneToMany(mappedBy = "grouptableByGroupId")
    public Collection<GrouplinkuserEntity> getGrouplinkusersById() {
        return grouplinkusersById;
    }

    public void setGrouplinkusersById(Collection<GrouplinkuserEntity> grouplinkusersById) {
        this.grouplinkusersById = grouplinkusersById;
    }

    @ManyToOne
    @JoinColumn(name = "ownerId", referencedColumnName = "_id")
    public UsertableEntity getUsertableByOwnerId() {
        return usertableByOwnerId;
    }

    public void setUsertableByOwnerId(UsertableEntity usertableByOwnerId) {
        this.usertableByOwnerId = usertableByOwnerId;
    }

    @OneToMany(mappedBy = "grouptableByGroupId")
    public Collection<HistoryinfotableEntity> getHistoryinfotablesById() {
        return historyinfotablesById;
    }

    public void setHistoryinfotablesById(Collection<HistoryinfotableEntity> historyinfotablesById) {
        this.historyinfotablesById = historyinfotablesById;
    }

    @OneToMany(mappedBy = "grouptableByBeApplyGroupId")
    public Collection<LinkapplyhistoryEntity> getLinkapplyhistoriesById() {
        return linkapplyhistoriesById;
    }

    public void setLinkapplyhistoriesById(Collection<LinkapplyhistoryEntity> linkapplyhistoriesById) {
        this.linkapplyhistoriesById = linkapplyhistoriesById;
    }
}
